{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 3 100\n",
      "11\n",
      "11\n"
     ]
    }
   ],
   "source": [
    "class A:\n",
    "    # 类变量\n",
    "    aa = 1\n",
    "    def __init__(self, x, y):\n",
    "        # 实例变量\n",
    "        self.x = x\n",
    "        self.y = y\n",
    "\n",
    "a = A(2, 3)\n",
    "# 类变量\n",
    "A.aa = 11\n",
    "# 实例变量\n",
    "a.aa = 100\n",
    "print(a.x, a.y, a.aa)\n",
    "print(A.aa)\n",
    "\n",
    "# AttributeError: type object 'A' has no attribute 'x'\n",
    "# print(A.x)\n",
    "\n",
    "\n",
    "b = A(3, 5)\n",
    "print(b.aa)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
